#include "Shield.h"
#include "Object3D.h"
#include <sstream>
#include <string>
#include <GL/glut.h>

const float PI = 3.1415926535f;

using namespace std;

// Constructor
Shield::Shield(){
	Object3D::Object3D("");
	smodel = glmReadOBJ("shield.obj");
	if(!smodel)
		exit(0);

	glmUnitize(smodel);
	glmFacetNormals(smodel);
	glmVertexNormals(smodel, 90.0);
}

Shield::Shield(string strTexturePath){
	Object3D::Object3D(strTexturePath);
	smodel = glmReadOBJ("shield.obj");
	if(!smodel)
		exit(0);

	glmUnitize(smodel);
	glmFacetNormals(smodel);
	glmVertexNormals(smodel, 90.0);
}

Shield::Shield(string strTexturePath, float posX, float posY, float posZ){
	Object3D::Object3D(strTexturePath);
	vTranslation = new Vec3f(posX, posY, posZ);
	smodel = glmReadOBJ("shield.obj");
	if(!smodel)
		exit(0);

	glmUnitize(smodel);
	glmFacetNormals(smodel);
	glmVertexNormals(smodel, 90.0);
}

void Shield::Draw(){
	glTranslatef(vTranslation->v[0],vTranslation->v[1],0.0f);
	glScalef(vScale->v[0], vScale->v[1], vScale->v[2]); //Scale
	glRotatef(vRotation->v[0], 1.0f, 0.0f, 0.0f); //Rotate about the x-axis
	glRotatef(vRotation->v[1], 0.0f, 1.0f, 0.0f); //Rotate about the y-axis
	glRotatef(vRotation->v[2], 0.0f, 0.0f, 1.0f); //Rotate about the z-axis

	glmDraw(smodel, GLM_SMOOTH| GLM_TEXTURE);

	glPopMatrix(); //Undo the move
	glPushMatrix(); //Save the current state
}
